package com.zsrt.java.day20161227.zzm.demo4;

import java.util.Random;
import java.util.Scanner;

public class MaiMa {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			System.out.println("杜绝赌博,建设美好家园(中奖概率为1/1000).....");
			System.out.println("是否继续，是/否  (y/n)");
			String temp1 = sc.next();
			if(temp1.equals("y")){
				System.out.println("程序已经退出.....");
				break;
			}
			System.out.println("请输入一个1-49的数:");
			int num = sc.nextInt();
			System.out.println(getNum(num));
			System.out.println("继续请按c,退出请按y");
			String temp = sc.next();
			if(temp.equals("y")){
				System.out.println("程序已经退出.....");
				break;
			}
		}
		
	}
	public static String getNum(int num){
		Random r = new Random();
		int ran =r.nextInt(49)+1;
		
		if(num<0||num>49){
			
			return "请重新输入";
		}
		if(ran==num){
			
			return "恭喜您中奖了......";
		}else{
			System.out.println("特码为："+ran);
			return "很遗憾,您没中奖";
		}
		
	}
}
